// See https://sequelize.org/master/manual/model-basics.html
// for more of what you can do here.
import { Sequelize, DataTypes, Model } from 'sequelize';
import { Application } from '../declarations';
import { HookReturn } from 'sequelize/types/hooks';

export default function (app: Application): typeof Model {
  const sequelizeClient: Sequelize = app.get('sequelizeClient');
  const hotels = sequelizeClient.define('hotels', {
    // 酒店名称
    name: {
      type: DataTypes.STRING,
      allowNull: false
    },
    // 点评
    dp: {
      type: DataTypes.STRING,
      allowNull: false
    },
    // 立减
    lj: {
      type: DataTypes.STRING,
      allowNull: false
    },
    // 供应商
    provider: {
      type: DataTypes.STRING,
      allowNull: false
    },
    // 排序
    sort: {
      type: DataTypes.STRING,
      allowNull: false
    },
    // 状态
    satus: {
      type: DataTypes.STRING,
      allowNull: false
    },
    // 报价
    price: {
      type: DataTypes.STRING,
      allowNull: false
    },
  }, {
    hooks: {
      beforeCount(options: any): HookReturn {
        options.raw = true;
      }
    }
  });

  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  (hotels as any).associate = function (models: any): void {
    // Define associations here
    // See https://sequelize.org/master/manual/assocs.html
  };

  return hotels;
}
